package org.zxp.effectiveJava.serializable;

public class TestMySingleton {
    public static void main(String[] args) throws Exception {
        /**获得单例类*/
        MySingleton INSTANCE = MySingleton.getInstance();
        System.out.println(INSTANCE.hashCode());

//        MySingleton INSTANCE2 = MySingleton.getInstance();
//        System.out.println(INSTANCE2.hashCode());
        /**将单例类对象序列化*/
        SerializableUtils.write(INSTANCE);
        /**将单例类对象再序列化*/
        MySingleton INSTANCE2 = (MySingleton)SerializableUtils.read();
        System.out.println(INSTANCE2.hashCode());
        System.out.println(INSTANCE == INSTANCE2);
    }
}
